<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>收货地址 - 奢享时光</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
  <style>
    :root {
      --primary-gradient: linear-gradient(135deg, #7F00FF, #E100FF);
      --secondary-gradient: linear-gradient(135deg, #00F5A0, #00D9F5);
      --primary-color: #7F00FF;
      --secondary-color: #00F5A0;
      --accent-color: #FFE600;
      --dark-bg: #2D1B69;
      --light-bg: #6B3FA0;
      --text-light: #FFFFFF;
      --text-secondary: #E0D5FF;
      --card-bg: rgba(255, 255, 255, 0.1);
      --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
      --border-radius: 16px;
      --border: 1px solid rgba(255, 255, 255, 0.18);
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      -webkit-tap-highlight-color: transparent;
    }

    body {
      font-family: 'Noto Sans SC', 'Poppins', sans-serif;
      background: var(--dark-bg);
      color: var(--text-light);
      font-size: 14px;
      line-height: 1.5;
      overflow-x: hidden;
    }

    a {
      text-decoration: none;
      color: inherit;
    }

    button {
      font-family: inherit;
      cursor: pointer;
      border: none;
      outline: none;
    }

    .app-container {
      max-width: 480px;
      margin: 0 auto;
      min-height: 100vh;
      background: linear-gradient(180deg, var(--dark-bg), var(--light-bg));
      position: relative;
      overflow: hidden;
      padding-bottom: 70px;
    }

    /* 背景装饰 */
    .bg-decoration {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 0;
      pointer-events: none;
      overflow: hidden;
    }

    .bg-circle {
      position: absolute;
      border-radius: 50%;
    }

    .bg-circle:nth-child(1) {
      width: 300px;
      height: 300px;
      top: -150px;
      right: -100px;
      background: radial-gradient(circle, rgba(225, 0, 255, 0.2), rgba(225, 0, 255, 0));
    }

    .bg-circle:nth-child(2) {
      width: 250px;
      height: 250px;
      bottom: 10%;
      left: -100px;
      background: radial-gradient(circle, rgba(0, 245, 160, 0.15), rgba(0, 245, 160, 0));
    }

    /* 顶部导航 */
    .header {
      position: sticky;
      top: 0;
      z-index: 100;
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      background: rgba(45, 27, 105, 0.8);
      padding: 15px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: var(--border);
    }

    .back-button {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.1);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
    }

    .page-title {
      font-size: 18px;
      font-weight: 600;
    }

    .header-actions {
      display: flex;
      gap: 15px;
    }

    .header-actions i {
      font-size: 18px;
      color: var(--text-light);
      opacity: 0.9;
    }

    /* 内容区域 */
    .content {
      position: relative;
      z-index: 1;
      padding: 20px;
    }

    /* 地址列表 */
    .address-list {
      margin-bottom: 80px;
    }

    .address-item {
      background: rgba(255, 255, 255, 0.1);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border: var(--border);
      border-radius: var(--border-radius);
      padding: 20px;
      margin-bottom: 15px;
      box-shadow: var(--shadow);
      position: relative;
    }

    .address-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 10px;
    }

    .address-name {
      font-size: 16px;
      font-weight: 600;
    }

    .address-phone {
      color: var(--text-secondary);
      font-size: 13px;
    }

    .address-content {
      margin-bottom: 15px;
      line-height: 1.6;
    }

    .address-tag {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 4px;
      background: var(--accent-color);
      color: var(--dark-bg);
      font-size: 12px;
      margin-right: 8px;
    }

    .address-actions {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-top: 1px solid rgba(255, 255, 255, 0.1);
      padding-top: 15px;
    }

    .default-setting {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .custom-switch {
      position: relative;
      display: inline-block;
      width: 48px;
      height: 24px;
    }

    .custom-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .switch-slider {
      position: absolute;
      cursor: pointer;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(255, 255, 255, 0.2);
      transition: .4s;
      border-radius: 30px;
    }

    .switch-slider:before {
      position: absolute;
      content: "";
      height: 20px;
      width: 20px;
      left: 2px;
      bottom: 2px;
      background-color: var(--text-light);
      transition: .4s;
      border-radius: 50%;
    }

    input:checked + .switch-slider {
      background-color: var(--accent-color);
    }

    input:checked + .switch-slider:before {
      transform: translateX(24px);
    }

    .action-buttons {
      display: flex;
      gap: 15px;
    }

    .edit-btn, .delete-btn {
      display: flex;
      align-items: center;
      gap: 5px;
      color: var(--text-secondary);
      font-size: 13px;
    }

    .edit-btn i, .delete-btn i {
      font-size: 14px;
    }

    .delete-btn {
      color: #ff4d4d;
    }

    /* 新增地址按钮 */
    .add-address-btn {
      position: fixed;
      bottom: 90px;
      left: 0;
      right: 0;
      max-width: 480px;
      margin: 0 auto;
      padding: 0 20px;
      z-index: 90;
    }

    .add-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      width: 100%;
      padding: 15px 0;
      background: var(--primary-gradient);
      border-radius: var(--border-radius);
      font-size: 16px;
      font-weight: 600;
      box-shadow: 0 5px 15px rgba(127, 0, 255, 0.3);
      transition: all 0.3s ease;
    }

    .add-btn i {
      font-size: 18px;
    }

    .add-btn:active {
      transform: scale(0.98);
    }

    /* 表单模态框 */
    .modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(5px);
      z-index: 1000;
      display: none;
    }

    .modal.active {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .modal-content {
      width: 90%;
      max-width: 440px;
      background: linear-gradient(135deg, var(--dark-bg), var(--light-bg));
      border-radius: var(--border-radius);
      padding: 20px;
      box-shadow: var(--shadow);
      position: relative;
      max-height: 90vh;
      overflow-y: auto;
    }

    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      padding-bottom: 10px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .modal-title {
      font-size: 18px;
      font-weight: 600;
    }

    .close-modal {
      width: 30px;
      height: 30px;
      border-radius: 50%;
      background: rgba(255, 255, 255, 0.1);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 16px;
    }

    .form-group {
      margin-bottom: 20px;
    }

    .form-label {
      display: block;
      margin-bottom: 8px;
      font-size: 14px;
      color: var(--text-secondary);
    }

    .form-input {
      width: 100%;
      padding: 12px 15px;
      background: rgba(255, 255, 255, 0.1);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 8px;
      color: var(--text-light);
      font-size: 14px;
      transition: all 0.3s ease;
    }

    .form-input:focus {
      border-color: var(--accent-color);
      outline: none;
    }

    .form-select {
      width: 100%;
      padding: 12px 15px;
      background: rgba(255, 255, 255, 0.1);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 8px;
      color: var(--text-light);
      font-size: 14px;
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 15px center;
    }

    .form-row {
      display: flex;
      gap: 10px;
    }

    .form-row .form-group {
      flex: 1;
    }

    .tag-options {
      display: flex;
      gap: 10px;
      margin-top: 10px;
    }

    .tag-option {
      padding: 8px 15px;
      border-radius: 30px;
      background: rgba(255, 255, 255, 0.1);
      font-size: 13px;
      cursor: pointer;
      transition: all 0.3s ease;
    }

    .tag-option.active {
      background: var(--accent-color);
      color: var(--dark-bg);
    }

    .submit-btn {
      width: 100%;
      padding: 15px 0;
      background: var(--primary-gradient);
      border-radius: var(--border-radius);
      font-size: 16px;
      font-weight: 600;
      margin-top: 10px;
      transition: all 0.3s ease;
    }

    .submit-btn:active {
      transform: scale(0.98);
    }

    /* 底部导航 */
    .bottom-nav {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      max-width: 480px;
      margin: 0 auto;
      background: rgba(45, 27, 105, 0.8);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border-top: var(--border);
      display: flex;
      justify-content: space-around;
      padding: 12px 0;
      z-index: 100;
    }

    .nav-button {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 5px;
      color: var(--text-secondary);
      font-size: 12px;
      padding: 5px 0;
      flex: 1;
      transition: all 0.3s ease;
    }

    .nav-button i {
      font-size: 18px;
      margin-bottom: 2px;
    }

    .nav-button.active {
      color: var(--accent-color);
    }

    /* 空状态 */
    .empty-state {
      text-align: center;
      padding: 50px 0;
      display: none;
    }

    .empty-state.active {
      display: block;
    }

    .empty-icon {
      font-size: 60px;
      color: var(--text-secondary);
      opacity: 0.5;
      margin-bottom: 20px;
    }

    .empty-text {
      font-size: 16px;
      color: var(--text-secondary);
      margin-bottom: 30px;
    }
  </style>
</head>
<body>
  <div class="app-container">
    <!-- 背景装饰 -->
    <div class="bg-decoration">
      <div class="bg-circle"></div>
      <div class="bg-circle"></div>
    </div>

    <!-- 顶部导航 -->
    <header class="header">
      <a href="profile.html" class="back-button">
        <i class="fas fa-arrow-left"></i>
      </a>
      <div class="page-title">收货地址</div>
      <div class="header-actions">
        <!-- 占位 -->
      </div>
    </header>

    <!-- 主要内容 -->
    <main class="content">
      <!-- 空状态 -->
      <div class="empty-state" id="empty-state">
        <div class="empty-icon">
          <i class="fas fa-map-marker-alt"></i>
        </div>
        <div class="empty-text">您还没有添加收货地址</div>
      </div>

      <!-- 地址列表 -->
      <div class="address-list" id="address-list">
        <!-- 地址项1 -->
        <div class="address-item">
          <div class="address-header">
            <div class="address-name">张先生</div>
            <div class="address-phone">138****5678</div>
          </div>
          <div class="address-content">
            <span class="address-tag">默认</span>
            <span class="address-tag">家</span>
            上海市静安区南京西路1266号恒隆广场28楼2801室
          </div>
          <div class="address-actions">
            <div class="default-setting">
              <label class="custom-switch">
                <input type="checkbox" checked>
                <span class="switch-slider"></span>
              </label>
              <span>默认地址</span>
            </div>
            <div class="action-buttons">
              <a href="javascript:void(0)" class="edit-btn" onclick="editAddress(0)">
                <i class="fas fa-pen"></i>
                <span>编辑</span>
              </a>
              <a href="javascript:void(0)" class="delete-btn" onclick="deleteAddress(0)">
                <i class="fas fa-trash"></i>
                <span>删除</span>
              </a>
            </div>
          </div>
        </div>

        <!-- 地址项2 -->
        <div class="address-item">
          <div class="address-header">
            <div class="address-name">张先生</div>
            <div class="address-phone">138****5678</div>
          </div>
          <div class="address-content">
            <span class="address-tag">公司</span>
            上海市浦东新区世纪大道100号上海环球金融中心15楼
          </div>
          <div class="address-actions">
            <div class="default-setting">
              <label class="custom-switch">
                <input type="checkbox">
                <span class="switch-slider"></span>
              </label>
              <span>默认地址</span>
            </div>
            <div class="action-buttons">
              <a href="javascript:void(0)" class="edit-btn" onclick="editAddress(1)">
                <i class="fas fa-pen"></i>
                <span>编辑</span>
              </a>
              <a href="javascript:void(0)" class="delete-btn" onclick="deleteAddress(1)">
                <i class="fas fa-trash"></i>
                <span>删除</span>
              </a>
            </div>
          </div>
        </div>
      </div>

      <!-- 添加地址按钮 -->
      <div class="add-address-btn">
        <button class="add-btn" id="add-address-btn">
          <i class="fas fa-plus"></i>
          <span>新增收货地址</span>
        </button>
      </div>
    </main>

    <!-- 地址表单模态框 -->
    <div class="modal" id="address-modal">
      <div class="modal-content">
        <div class="modal-header">
          <div class="modal-title" id="modal-title">新增收货地址</div>
          <button class="close-modal" id="close-modal">
            <i class="fas fa-times"></i>
          </button>
        </div>
        <form id="address-form">
          <input type="hidden" id="form-index" value="-1">
          <div class="form-row">
            <div class="form-group">
              <label class="form-label">收货人</label>
              <input type="text" class="form-input" id="form-name" placeholder="请输入姓名">
            </div>
            <div class="form-group">
              <label class="form-label">手机号码</label>
              <input type="tel" class="form-input" id="form-phone" placeholder="请输入手机号">
            </div>
          </div>
          <div class="form-group">
            <label class="form-label">所在地区</label>
            <div class="form-row">
              <div class="form-group">
                <select class="form-select" id="form-province">
                  <option value="">省份</option>
                  <option value="上海市">上海市</option>
                  <option value="北京市">北京市</option>
                  <option value="广东省">广东省</option>
                  <option value="江苏省">江苏省</option>
                  <option value="浙江省">浙江省</option>
                </select>
              </div>
              <div class="form-group">
                <select class="form-select" id="form-city">
                  <option value="">城市</option>
                  <option value="上海市">上海市</option>
                  <option value="杭州市">杭州市</option>
                  <option value="南京市">南京市</option>
                  <option value="广州市">广州市</option>
                  <option value="深圳市">深圳市</option>
                </select>
              </div>
            </div>
          </div>
          <div class="form-group">
            <label class="form-label">详细地址</label>
            <input type="text" class="form-input" id="form-address" placeholder="街道、楼牌号等">
          </div>
          <div class="form-group">
            <label class="form-label">地址标签</label>
            <div class="tag-options">
              <div class="tag-option active" data-tag="家">家</div>
              <div class="tag-option" data-tag="公司">公司</div>
              <div class="tag-option" data-tag="学校">学校</div>
            </div>
          </div>
          <div class="form-group">
            <label class="custom-switch">
              <input type="checkbox" id="form-default">
              <span class="switch-slider"></span>
            </label>
            <span>设为默认收货地址</span>
          </div>
          <button type="submit" class="submit-btn">保存</button>
        </form>
      </div>
    </div>

    <!-- 底部导航 -->
    <nav class="bottom-nav">
      <a href="index.html" class="nav-button">
        <i class="fas fa-home"></i>
        <span>首页</span>
      </a>
      <a href="groupbuy.html" class="nav-button">
        <i class="fas fa-users"></i>
        <span>拼团</span>
      </a>
      <a href="shares.html" class="nav-button">
        <i class="fas fa-chart-line"></i>
        <span>股权</span>
      </a>
      <a href="profile.html" class="nav-button active">
        <i class="fas fa-user"></i>
        <span>我的</span>
      </a>
    </nav>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      // 获取元素
      const addressList = document.getElementById('address-list');
      const emptyState = document.getElementById('empty-state');
      const addAddressBtn = document.getElementById('add-address-btn');
      const addressModal = document.getElementById('address-modal');
      const closeModal = document.getElementById('close-modal');
      const modalTitle = document.getElementById('modal-title');
      const addressForm = document.getElementById('address-form');
      const formIndex = document.getElementById('form-index');
      const formName = document.getElementById('form-name');
      const formPhone = document.getElementById('form-phone');
      const formProvince = document.getElementById('form-province');
      const formCity = document.getElementById('form-city');
      const formAddress = document.getElementById('form-address');
      const formDefault = document.getElementById('form-default');
      const tagOptions = document.querySelectorAll('.tag-option');
      
      // 检查是否有地址
      function checkEmptyState() {
        const addressItems = addressList.querySelectorAll('.address-item');
        if (addressItems.length === 0) {
          emptyState.classList.add('active');
          addressList.style.display = 'none';
        } else {
          emptyState.classList.remove('active');
          addressList.style.display = 'block';
        }
      }
      
      // 初始化检查
      checkEmptyState();
      
      // 打开新增地址模态框
      addAddressBtn.addEventListener('click', function() {
        modalTitle.textContent = '新增收货地址';
        formIndex.value = '-1';
        addressForm.reset();
        
        // 重置标签选择
        tagOptions.forEach(option => {
          option.classList.remove('active');
        });
        tagOptions[0].classList.add('active');
        
        addressModal.classList.add('active');
      });
      
      // 关闭模态框
      closeModal.addEventListener('click', function() {
        addressModal.classList.remove('active');
      });
      
      // 点击模态框外部关闭
      addressModal.addEventListener('click', function(e) {
        if (e.target === addressModal) {
          addressModal.classList.remove('active');
        }
      });
      
      // 标签选择
      tagOptions.forEach(option => {
        option.addEventListener('click', function() {
          tagOptions.forEach(opt => {
            opt.classList.remove('active');
          });
          this.classList.add('active');
        });
      });
      
      // 编辑地址
      window.editAddress = function(index) {
        const addressItems = addressList.querySelectorAll('.address-item');
        const item = addressItems[index];
        
        const name = item.querySelector('.address-name').textContent;
        const phone = item.querySelector('.address-phone').textContent;
        const address = item.querySelector('.address-content').textContent.trim();
        const isDefault = item.querySelector('.custom-switch input').checked;
        
        // 提取地址标签
        const tagElements = item.querySelectorAll('.address-tag');
        let selectedTag = '';
        tagElements.forEach(tag => {
          if (tag.textContent !== '默认') {
            selectedTag = tag.textContent;
          }
        });
        
        // 填充表单
        formIndex.value = index;
        formName.value = name;
        formPhone.value = phone;
        formProvince.value = '上海市'; // 假设数据
        formCity.value = '上海市'; // 假设数据
        formDefault.checked = isDefault;
        
        // 提取详细地址 (简化处理)
        formAddress.value = address.replace(/默认|家|公司|学校/g, '').trim();
        
        // 设置标签
        tagOptions.forEach(option => {
          option.classList.remove('active');
          if (option.dataset.tag === selectedTag) {
            option.classList.add('active');
          }
        });
        
        modalTitle.textContent = '编辑收货地址';
        addressModal.classList.add('active');
      };
      
      // 删除地址
      window.deleteAddress = function(index) {
        if (confirm('确定要删除这个地址吗？')) {
          const addressItems = addressList.querySelectorAll('.address-item');
          addressItems[index].remove();
          checkEmptyState();
        }
      };
      
      // 表单提交
      addressForm.addEventListener('submit', function(e) {
        e.preventDefault();
        
        // 获取表单数据
        const name = formName.value;
        const phone = formPhone.value;
        const province = formProvince.value;
        const city = formCity.value;
        const address = formAddress.value;
        const isDefault = formDefault.checked;
        
        // 获取选中的标签
        let selectedTag = '';
        tagOptions.forEach(option => {
          if (option.classList.contains('active')) {
            selectedTag = option.dataset.tag;
          }
        });
        
        // 表单验证 (简化)
        if (!name || !phone || !province || !city || !address) {
          alert('请填写完整信息');
          return;
        }
        
        const index = parseInt(formIndex.value);
        
        if (index === -1) {
          // 新增地址
          const html = `
            <div class="address-item">
              <div class="address-header">
                <div class="address-name">${name}</div>
                <div class="address-phone">${phone}</div>
              </div>
              <div class="address-content">
                ${isDefault ? '<span class="address-tag">默认</span>' : ''}
                <span class="address-tag">${selectedTag}</span>
                ${province}${city}${address}
              </div>
              <div class="address-actions">
                <div class="default-setting">
                  <label class="custom-switch">
                    <input type="checkbox" ${isDefault ? 'checked' : ''}>
                    <span class="switch-slider"></span>
                  </label>
                  <span>默认地址</span>
                </div>
                <div class="action-buttons">
                  <a href="javascript:void(0)" class="edit-btn" onclick="editAddress(${addressList.querySelectorAll('.address-item').length})">
                    <i class="fas fa-pen"></i>
                    <span>编辑</span>
                  </a>
                  <a href="javascript:void(0)" class="delete-btn" onclick="deleteAddress(${addressList.querySelectorAll('.address-item').length})">
                    <i class="fas fa-trash"></i>
                    <span>删除</span>
                  </a>
                </div>
              </div>
            </div>
          `;
          
          addressList.insertAdjacentHTML('beforeend', html);
        } else {
          // 更新地址
          const addressItems = addressList.querySelectorAll('.address-item');
          const item = addressItems[index];
          
          item.querySelector('.address-name').textContent = name;
          item.querySelector('.address-phone').textContent = phone;
          
          // 更新地址内容
          const contentHtml = `
            ${isDefault ? '<span class="address-tag">默认</span>' : ''}
            <span class="address-tag">${selectedTag}</span>
            ${province}${city}${address}
          `;
          item.querySelector('.address-content').innerHTML = contentHtml;
          
          // 更新默认状态
          item.querySelector('.custom-switch input').checked = isDefault;
        }
        
        // 如果设为默认，取消其他默认
        if (isDefault) {
          const switches = addressList.querySelectorAll('.custom-switch input');
          switches.forEach((switchEl, i) => {
            if (i !== index) {
              switchEl.checked = false;
              
              // 移除默认标签
              const addressItem = switchEl.closest('.address-item');
              const defaultTag = addressItem.querySelector('.address-tag');
              if (defaultTag && defaultTag.textContent === '默认') {
                defaultTag.remove();
              }
            }
          });
        }
        
        addressModal.classList.remove('active');
        checkEmptyState();
        
        // 页面加载动画
        const addressItems = document.querySelectorAll('.address-item');
        addressItems.forEach((item, index) => {
          item.style.opacity = '0';
          item.style.transform = 'translateY(20px)';
          item.style.transition = `opacity 0.5s ease, transform 0.5s ease`;
          
          setTimeout(() => {
            item.style.opacity = '1';
            item.style.transform = 'translateY(0)';
          }, 100 + (index * 150));
        });
      });
      
      // 默认地址切换
      const defaultSwitches = document.querySelectorAll('.custom-switch input');
      defaultSwitches.forEach((switchEl, index) => {
        switchEl.addEventListener('change', function() {
          if (this.checked) {
            // 取消其他默认
            defaultSwitches.forEach((sw, i) => {
              if (i !== index) {
                sw.checked = false;
                
                // 移除默认标签
                const addressItem = sw.closest('.address-item');
                const tags = addressItem.querySelectorAll('.address-tag');
                tags.forEach(tag => {
                  if (tag.textContent === '默认') {
                    tag.remove();
                  }
                });
              }
            });
            
            // 添加默认标签
            const addressItem = this.closest('.address-item');
            const content = addressItem.querySelector('.address-content');
            const hasDefault = Array.from(content.querySelectorAll('.address-tag')).some(tag => tag.textContent === '默认');
            
            if (!hasDefault) {
              const tag = document.createElement('span');
              tag.className = 'address-tag';
              tag.textContent = '默认';
              content.insertBefore(tag, content.firstChild);
            }
          } else {
            // 移除默认标签
            const addressItem = this.closest('.address-item');
            const tags = addressItem.querySelectorAll('.address-tag');
            tags.forEach(tag => {
              if (tag.textContent === '默认') {
                tag.remove();
              }
            });
          }
        });
      });
      
      // 页面加载动画
      const addressItems = document.querySelectorAll('.address-item');
      addressItems.forEach((item, index) => {
        item.style.opacity = '0';
        item.style.transform = 'translateY(20px)';
        item.style.transition = `opacity 0.5s ease, transform 0.5s ease`;
        
        setTimeout(() => {
          item.style.opacity = '1';
          item.style.transform = 'translateY(0)';
        }, 100 + (index * 150));
      });
    });
  </script>
</body>
</html> 